#include "MVector3D.hpp"
#include <math.h>

MVector3D::MVector3D()
{
	x = 0; y = 0; z = 0;
}

MVector3D::MVector3D(const float &newX, const float &newY, const float &newZ)
{
	x = newX; y = newY; z = newZ;
}

MVector3D::MVector3D(const MVector3D &vecRef)
{
	x = vecRef.x; y = vecRef.y; z = vecRef.z;
}

MVector3D::~MVector3D()
{
}

void MVector3D::Set(const float &newX, const float &newY, const float &newZ)
{
	x = newX; y = newY; z = newZ;
}

void MVector3D::Normalize()
{
	float length = GetLength();

	x = x / length;
	y = y / length;
	z = z / length;
}

MVector3D MVector3D::CrossProduct(const MVector3D &inVector)
{
	return MVector3D( y*inVector.z - inVector.y*z, inVector.x*z - x*inVector.z,	x*inVector.y - inVector.x*y );
}

float MVector3D::DotProduct(const MVector3D &inVector)
{
	return ( x*inVector.x + y*inVector.y + z*inVector.z );
}

float MVector3D::GetLength()
{
	return sqrt( x*x + y*y + z*z );
}